package com.macro.mall.common.configuration;

import com.macro.mall.common.api.constants.EnvironmentNameConstants;
import com.macro.mall.common.api.enums.EnvironmentEnum;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

/**
 * class
 *
 * @author xuyanjun
 * @date 2019-09-12
 */
@Getter
@Setter
@Configuration
public class AppEnvironmentConfiguration {

    private EnvironmentEnum environmentEnum = EnvironmentEnum.PROD;

    @Profile(value = {EnvironmentNameConstants.DEV})
    @Bean
    public Inner dev() {
        environmentEnum = EnvironmentEnum.DEV;
        return new Inner();
    }

    @Profile(value = {EnvironmentNameConstants.TEST})
    @Bean
    public Inner test() {
        environmentEnum = EnvironmentEnum.TEST;
        return new Inner();
    }

    @Profile(value = {EnvironmentNameConstants.PROD})
    @Bean
    public Inner prod() {
        environmentEnum = EnvironmentEnum.PROD;
        return new Inner();
    }

    public static class Inner {
    }
}
